#pragma once

#include <iostream>
#include <vector>
#include <unistd.h>

using namespace std;

int taskNum = 3;

void PrintLOG()
{
  cout << "PID: " << getpid() << " 正在执行打印日志的任务…" << endl;
}

void InsertSQL()
{
  cout << "PID: " << getpid() << " 正在执行数据库插入的任务…" << endl;
}

void NetRequst()
{
  cout << "PID: " << getpid() << " 正在执行网络请求的任务…" << endl;
}

typedef void(*func_t)();

class Task
{
public:
  Task()
  {
    funcs.push_back(PrintLOG);
    funcs.push_back(InsertSQL);
    funcs.push_back(NetRequst);
  }

  void Execute(int command)
  {
    if(command >= 0 && command < funcs.size())
      funcs[command](); //执行对应任务
    else
      cout << "暂时没有找到此任务" << endl;
  }

private:
  vector<func_t> funcs;
};
